home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 8
/
The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO
/
prg_casm
/
snpd9611.zip
/
HEXDUMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-11-24
|
2KB
|
83 lines
.I 0 2
/* +++Date last modified: 17-Feb-1996 */
.I 3 1
** Originally written By Paul Edwards
.D 4 1
.I 5 4
**
** Modified for SNIPPETS by Bob Stout
**
** Uses ERR_EXIT.C and FERROF.C, also in SNIPPETS
.I 11 1
#include "errors.h"
.D 14 1
.I 18 1
long start, count, length;
.D 19 1
.I 21 1
ErrExit("Usage: HEXDUMP file_name [start] [length]");
.D 22 4
.I 26 1
sscanf(argv[2], "%li", &start);
.D 27 1
.I 29 1
sscanf(argv[3], "%li", &count);
.D 30 1
.I 31 13
fp = cant(argv[1], "rb");
fseek(fp, 0L, SEEK_END);
length = ftell(fp);
if (start > length)
{
ErrExit("Can't find position %ld in a %ld byte file",
start, length);
}
if (fseek(fp, start, SEEK_SET))
ErrExit("Unable to find position %ld", start);
.D 32 7
.I 44 3
int c, pos1, pos2, posn = (int)(start % 16L);
long x = 0L;
char prtln[80];
.D 45 3
.I 50 1
if (0 == (posn % 16) || 0 == x)
.D 51 1
.I 53 12
sprintf(prtln,"%0.6X:", start + x);
prtln[7] = ' ';
pos1 = 8 + (int)(3 * posn);
if (posn > 3)
++pos1;
if (posn > 7)
++pos1;
if (posn > 11)
++pos1;
pos2 = 60 + (int)(posn);
}
sprintf(prtln + pos1, "%0.2X ", c);
.D 54 5
.I 61 1
pos1 += 3;
.D 62 1
.I 64 1
if (posn % 4 == 3)
.D 65 1
.I 66 2
if (posn % 16 == 15)
{
.D 67 1
.I 68 6
posn = 0;
}
else ++posn;
++x;
}
if (posn % 16)
.D 69 3
.D 75 14